<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Index extends CI_Controller
{
    private $token_user,$admin_id;
	public function __construct()
	{
		parent::__construct();
		$this->load->model(array('admin_model', 'admin_group_model'));
        $this->token_user = check_token();
        $this->admin_id = $this->token_user[0];
	}
	
    public function index()
    {
		$row        = $this->admin_model->get_by_id($this->admin_id);
        $menu        = $this->admin_group_model->load_menu($row['group_id']);
        response_json($menu,0,'ok');
	}
	public function userinfo(){
        $data['username'] = $this->token_user['1'];
        response_json($data,0,'ok');
    }

    /**
     * 首页统计
     * 缓存时间为一天。
     */
    public function data(){
        $this->load->model(array('report_model'));
        $where = "where today='".date('Y-m-d')."'";
        $list = $this->report_model->result_count($where);
        $data['num'] = $list;
//        echo $this->db->last_query();
//        dd($data);
        response_json($data,0,'ok');
    }
	
}